<?php

namespace App\Repositories;

use App\Models\ExpressCompany;

class ExpressCompanyRepository extends BaseRepository
{
    public function model()
    {
        return ExpressCompany::class;
    }

    /**
     * 获取快递公司列表
     * Date: 2018/05/10
     * @param $expressCompany_name
     * @param $limit
     * @param $code_name
     * @param $phone
     * @author Tenny
     * @return \Illuminate\Database\Eloquent\Collection|static[]
     */
    public function getExpressCompanys($expressCompany_name = false, $limit = false, $code_name = false, $phone = false)
    {
        if ($expressCompany_name !== false) {
            $this->where('designation', 'like', '%' . $expressCompany_name . '%');
        }
        if ($code_name !== false) {
            $this->where('code_name', '=', $code_name);
        }
        if ($phone !== false) {
            $this->where('phone', '=', $phone);
        }
        if ($limit !== false) {
            $couriers = $this->paginate($limit);
        } else {
            $couriers = $this->get();
        }
        return $couriers;
    }

    protected function serialization(array $attributes)
    {
        // TODO: Implement serialization() method.
    }
}